﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;
using System.Net;

using EHTWebsite.Code;
using EHTWebsiteProject.Code.BLL;
using System.Resources;
using System.Threading;
using System.Globalization;
using System.Text;
using Telerik.Web.UI;
using System.Collections.Generic;
using EHTWebsiteProject.Code.Entity;

namespace EHTWebsiteProject.Administrator
{
    public partial class EHTConfigNews : System.Web.UI.Page
    {
        public Boolean IsVN = true;
        private String Loai = "";
        private String languageCode = "vi-VN";
        private ResourceManager rm = new ResourceManager("Resources.SiteMap", System.Reflection.Assembly.Load("App_GlobalResources"));

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {

                try
                {
                    languageCode = Session[HangSo.LANGUAGE_CODE].ToString();
                    if (languageCode == "en-us")
                    {
                        IsVN = false;
                    }

                }
                catch (Exception ex)
                {
                }

                Thread.CurrentThread.CurrentCulture = new CultureInfo(languageCode);
                LoadLanguage(Thread.CurrentThread.CurrentCulture);
            }
        }

        /// <summary>
        /// Ham load ngon ngu
        /// </summary>
        /// <param name="ci"></param>
        public void LoadLanguage(CultureInfo ci)
        {
            lbSave.Text = rm.GetString("lbSave", ci);
            lbBack.Text = rm.GetString("lbBack", ci);
            lbParameters_Advanced.Text = rm.GetString("lbParameters_Advanced", ci);
            lbParameters_Basic.Text = rm.GetString("lbParameters_Basic", ci);            
        }

        /// <summary>
        /// Ham lay cac tham so
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public ParaNews GetParaNews(ParaNews theParaNews)
        {                       
                theParaNews.ShowArticle = rbTenNhom_Show.Checked.ToString();           
                theParaNews.ShowNavigation = rbMoTa_Show.Checked.ToString();            
                theParaNews.NumIntro = 1;          
            
                theParaNews.Columns = 1;          
         
                theParaNews.DisplayIntroText = rbDisplay_Yes.Checked.ToString();                      
                theParaNews.DisplayReadMore = rbReadmore_Yes.Checked.ToString();                    
                theParaNews.DisplayThumb = rbthum_Yes.Checked.ToString();                      
                theParaNews.DisplayImage = rdDisplayImage_Yes.Checked.ToString();
           

            theParaNews.Numchar = "";
            try
            {
                theParaNews.WidthOfThumb = Int32.Parse(txtWidthOfthumbs.Text);
            }
            catch
            {
                theParaNews.WidthOfThumb = 1;
            }

            theParaNews.Pagination = "";
            theParaNews.ShowArticleRelation = "";
            return theParaNews;
        }

        protected void ImgSave_Click(object sender, ImageClickEventArgs e)
        {
            // lấy giá trị trên sesion  gán vào mảng
            ArrayList arr = (ArrayList)Session["ArrayListConfig"];
            for (int i = 0; i < arr.Count; i++)
            {
                ParaNews theParaNews = new ParaNews();
                ParaNews theNews = new ParaNews();
                theParaNews = GetParaNews(theNews);
                theParaNews.ParaNewsID = Int32.Parse(arr[i].ToString());
                ThamSoProvider.UpdateParaNews(theParaNews);
            }

            Response.Redirect("EHTArticle.aspx");
        }
    }
}